package com.bc004346.travelus.model.abstracts;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;

import com.bc004346.travelus.R;

/**
 * Created by Renats on 9/4/2014.
 * Generic single fragment container
 */
public abstract class SingleFragmentActivity extends BaseFragmentActivity {

    protected abstract Fragment getFragment();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        FragmentManager fm = getSupportFragmentManager();
        Fragment fragment = fm.findFragmentById(R.id.activity_fragment_frame);

        if (fragment == null) {
            fragment = getFragment();
            fm.beginTransaction()
                    .add(R.id.activity_fragment_frame, fragment)
                    .commit();
        }
    }
}
